import java.util.Scanner;

class LoanCalculator {
    private double loanAmount; // 贷款总额（万元）
    private int months;        // 贷款时间（月）
    private double annualRate; // 年利率（%）

    // 构造方法
    public LoanCalculator(double loanAmount, int months, double annualRate) {
        this.loanAmount = loanAmount;
        this.months = months;
        this.annualRate = annualRate;
    }

    // 计算等额本金的总利息
    public double calculatePrincipalInterest() {
        double monthlyRate = annualRate / 12 / 100; // 月利率
        return (months + 1) * loanAmount * monthlyRate / 2;
    }

    // 计算等额本息的总利息
    public double calculateEqualInstallmentInterest() {
        double monthlyRate = annualRate / 12 / 100; // 月利率
        double numerator = loanAmount * monthlyRate * Math.pow(1 + monthlyRate, months);
        double denominator = Math.pow(1 + monthlyRate, months) - 1;
        double totalRepayment = numerator / denominator * months;
        return totalRepayment - loanAmount;
    }

    // 主方法
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 输入贷款总额、贷款时间和年利率
        System.out.println("请输入贷款总额（万元）：");
        double loanAmount = scanner.nextDouble();
        System.out.println("请输入贷款时间（月）：");
        int months = scanner.nextInt();
        System.out.println("请输入年利率（%）：");
        double annualRate = scanner.nextDouble();

        // 创建贷款计算器对象
        LoanCalculator calculator = new LoanCalculator(loanAmount, months, annualRate);

        // 计算两种还款方式的总利息
        double principalInterest = calculator.calculatePrincipalInterest();
        double equalInstallmentInterest = calculator.calculateEqualInstallmentInterest();

        // 输出结果
        System.out.printf("等额本金还款的总利息为：%.2f 万元\n", principalInterest);
        System.out.printf("等额本息还款的总利息为：%.2f 万元\n", equalInstallmentInterest);

        scanner.close();
    }
}